package alpha.com.google.code.mechanic.janitor.ui.handler;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import alpha.com.google.code.mechanic.janitor.ui.ContextsMgtDialog;

/**
 * The class is to handle the command of sub menu item: "Context Management"
 * of the Workspace Janitor menu.
 * 
 * Last_edited: Nov 29, 2014
 * 
 * @History
 * 1. Delete the field ContextData ctxData.
 * @author jingjiejiang
 * @since Nov 29, 2014
 * 
 * @author jingjiejiang
 * @since Aug 4, 2014 
 *
 */
public class CtxMgtHandler extends AbstractHandler {
  
  public Object execute(ExecutionEvent event) throws ExecutionException {
    
    Shell parentShell = Display.getCurrent().getActiveShell();

    ContextsMgtDialog dialog = new ContextsMgtDialog(parentShell, false);
    int dialogopen = dialog.open();
    if (dialogopen == Dialog.OK || dialogopen == Dialog.CANCEL) {
      
      dialog.close(); 
      
//      // to update the task list table
//      JanitorView.UpdateJanitor updateJanitor = new JanitorView.UpdateJanitor();
//      updateJanitor.updateTskTbl();
      
      // In dialog mode, there is no need to update any table
    }
    return null;
  }

}
